package com.hongxin.nw.netty.utils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;

/**
 * @remark --
 * @author: GuoXiaolin
 * @date 2019/7/9 9:17
 * @Version 1.0
 * @Descibe
 */
public class MyJson {

    private int code;
    private String msg;
    private String stringdata;
//    private JSONObject jobData;
//    private JSONArray array;

    public MyJson(String txt) throws JSONException  {
        JSONObject jsonObject = JSONObject.parseObject(txt);
        this.code = jsonObject.getIntValue("code");
        this.msg = jsonObject.getString("msg");
        this.stringdata = jsonObject.getString("data");
    }
    public MyJson(JSONObject jsonObject) throws JSONException {
        this.code = jsonObject.getIntValue("code");
        this.msg = jsonObject.getString("msg");
        this.stringdata = jsonObject.getString("data");
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getStringdata() {
        return stringdata;
    }

    public void setStringdata(String stringdata) {
        this.stringdata = stringdata;
    }

    public JSONObject getJobData() {
        return JSONObject.parseObject(this.stringdata);
    }

    public JSONArray getArray() {
        return JSONObject.parseArray(this.stringdata);
    }
    public int getIntData() {
        return Integer.parseInt(this.stringdata);
    }

}
